﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Shared/MasterAdmin.master" AutoEventWireup="true"
    CodeFile="FAQs.aspx.cs" Inherits="Admin_ListFAQs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
    </asp:ScriptManagerProxy>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <h1>
                FAQs</h1>
            <asp:ListView ID="ListView1" runat="server" DataKeyNames="faId" DataSourceID="SqlDataSource1"
                InsertItemPosition="LastItem" OnItemInserting="ItemInserting" OnItemUpdating="ListView1_ItemUpdating"
                Style="margin-left: 0px">
                <AlternatingItemTemplate>
                    <tr style="background-color: #FFFFFF; color: #284775;">
                        <td>
                            <asp:Label ID="faIdLabel" runat="server" Text='<%# Eval("faId") %>' />
                        </td>
                        <td>
                            <asp:Label ID="faQuestionLabel" runat="server" Text='<%# Eval("faQuestion") %>' />
                        </td>
                        <td>
                            <asp:Label ID="faAnswerLabel" runat="server" Text='<%# Eval("faAnswer") %>' />
                        </td>
                        <td>
                            <asp:CheckBox ID="faActiveCheckBox" runat="server" Checked='<%# Eval("faActive") %>'
                                Enabled="false" />
                        </td>
                        <td>
                            <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                        </td>
                    </tr>
                </AlternatingItemTemplate>
                <EditItemTemplate>
                    <tr style="background-color: #999999;">
                        <td>
                            <asp:Label ID="faIdLabel1" runat="server" Text='<%# Eval("faId") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="faQuestionTextBox" TextMode="MultiLine" runat="server" Text='<%# Bind("faQuestion") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="faAnswerTextBox" TextMode="MultiLine" runat="server" Text='<%# Bind("faAnswer") %>' />
                        </td>
                        <td>
                            <asp:CheckBox ID="faActiveCheckBox" runat="server" Checked='<%# Bind("faActive") %>' />
                        </td>
                        <td>
                            <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
                            <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
                        </td>
                    </tr>
                </EditItemTemplate>
                <EmptyDataTemplate>
                    <table id="Table1" runat="server" style="background-color: #FFFFFF; border-collapse: collapse;
                        border-color: #999999; border-style: none; border-width: 1px;">
                        <tr>
                            <td>
                                No data was returned.
                            </td>
                        </tr>
                    </table>
                </EmptyDataTemplate>
                <InsertItemTemplate>
                    <tr style="">
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            <asp:TextBox ID="faQuestionTextBox" TextMode="MultiLine" runat="server" Text='<%# Bind("faQuestion") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="faAnswerTextBox" TextMode="MultiLine" runat="server" Text='<%# Bind("faAnswer") %>' />
                        </td>
                        <td>
                            <asp:CheckBox ID="faActiveCheckBox" runat="server" Checked='<%# Bind("faActive") %>' />
                        </td>
                        <td>
                            <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                            <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
                        </td>
                    </tr>
                </InsertItemTemplate>
                <ItemTemplate>
                    <tr style="background-color: #E0FFFF; color: #333333;">
                        <td>
                            <asp:Label ID="faIdLabel" runat="server" Text='<%# Eval("faId") %>' />
                        </td>
                        <td>
                            <asp:Label ID="faQuestionLabel" runat="server" Text='<%# Eval("faQuestion") %>' />
                        </td>
                        <td>
                            <asp:Label ID="faAnswerLabel" runat="server" Text='<%# Eval("faAnswer") %>' />
                        </td>
                        <td>
                            <asp:CheckBox ID="faActiveCheckBox" runat="server" Checked='<%# Eval("faActive") %>'
                                Enabled="false" />
                        </td>
                        <td>
                            <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                        </td>
                    </tr>
                </ItemTemplate>
                <LayoutTemplate>
                    <table id="Table2" runat="server">
                        <tr id="Tr1" runat="server">
                            <td id="Td1" runat="server">
                                <table id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;
                                    border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px;
                                    font-family: Verdana, Arial, Helvetica, sans-serif;">
                                    <tr id="Tr2" runat="server" style="background-color: #E0FFFF; color: #333333;">
                                        <th id="Th1" runat="server">
                                            Id
                                        </th>
                                        <th id="Th2" runat="server">
                                            Question
                                        </th>
                                        <th id="Th3" runat="server">
                                            Answer
                                        </th>
                                        <th id="Th4" runat="server">
                                            Active
                                        </th>
                                        <th id="Th5" runat="server">
                                        </th>
                                    </tr>
                                    <tr id="itemPlaceholder" runat="server">
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr id="Tr3" runat="server">
                            <td id="Td2" runat="server" style="text-align: center; background-color: #5D7B9D;
                                font-family: Verdana, Arial, Helvetica, sans-serif; color: #FFFFFF">
                                <asp:DataPager ID="DataPager1" runat="server">
                                    <Fields>
                                        <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
                                    </Fields>
                                </asp:DataPager>
                            </td>
                        </tr>
                    </table>
                </LayoutTemplate>
                <SelectedItemTemplate>
                    <tr style="background-color: #E2DED6; font-weight: bold; color: #333333;">
                        <td>
                            <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                        </td>
                        <td>
                            <asp:Label ID="faIdLabel" runat="server" Text='<%# Eval("faId") %>' />
                        </td>
                        <td>
                            <asp:Label ID="faQuestionLabel" runat="server" Text='<%# Eval("faQuestion") %>' />
                        </td>
                        <td>
                            <asp:Label ID="faAnswerLabel" runat="server" Text='<%# Eval("faAnswer") %>' />
                        </td>
                        <td>
                            <asp:CheckBox ID="faActiveCheckBox" runat="server" Checked='<%# Eval("faActive") %>'
                                Enabled="false" />
                        </td>
                    </tr>
                </SelectedItemTemplate>
            </asp:ListView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ShopConnectionString %>"
                DeleteCommand="DELETE FROM [FAQs] WHERE [faId] = @faId" InsertCommand="INSERT INTO [FAQs] ([faQuestion], [faAnswer], [faActive]) VALUES (@faQuestion, @faAnswer, @faActive)"
                SelectCommand="SELECT * FROM [FAQs]" UpdateCommand="UPDATE [FAQs] SET [faQuestion] = @faQuestion, [faAnswer] = @faAnswer, [faActive] = @faActive WHERE [faId] = @faId">
                <DeleteParameters>
                    <asp:Parameter Name="faId" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="faQuestion" Type="String" />
                    <asp:Parameter Name="faAnswer" Type="String" />
                    <asp:Parameter Name="faActive" Type="Boolean" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="faQuestion" Type="String" />
                    <asp:Parameter Name="faAnswer" Type="String" />
                    <asp:Parameter Name="faActive" Type="Boolean" />
                    <asp:Parameter Name="faId" Type="Int32" />
                </UpdateParameters>
            </asp:SqlDataSource>
            <asp:Label ID="lblMessage" runat="server" Text="" ForeColor="red"></asp:Label>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
